﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Threading;
using System.Web.Routing;

namespace Framework.Project.Web.Mvc.Html.Test
{
  public class HomeController : Controller
  {
    private const string closeLoadingPaneScript = "closeLoadingPane();";
    private const string succesfullyLoginScript = "alert('Succesfully Logged...')";
    
    public ActionResult Index()
    {
      //Stopwatch sw = new Stopwatch();
      //sw.Start();

      //CLoginPage loginPage = new CLoginPage();
      //loginPage.htmlVersion = HtmlVersion.Html_v5;
      //loginPage.htmlIsMinify = false;
      //string resultStr = loginPage.GetHtmlString(RenderMode.NormalWithValue);

      // Örn:
      //if (this.request.IsAjaxRequest())
      //{
      //  // 
      //}

      CDbConnectionErrorPage errorpage = new CDbConnectionErrorPage();
      errorpage.htmlVersion = HtmlVersion.Html_v5;
      errorpage.htmlIsMinify = true;
      string resultStr = errorpage.GetHtmlString(RenderMode.NormalWithValue);

      //CPageNotFoundPage pageNotFound = new CPageNotFoundPage();
      //string resultStr = pageNotFound.GetHtmlString(RenderMode.NormalWithValue);

      //sw.Stop();
      //string resulttime = sw.ElapsedMilliseconds.ToString();

      return Content(resultStr);

      //return View();
    }

    // Login
    public ActionResult Login(string username, string password)
    {
      Thread.Sleep(1000);
      return Content(closeLoadingPaneScript + succesfullyLoginScript);
    }
  }
}
